Skip to content

feat: implemented getAccountInfoQuery TCK endpoint#2081

Merged
aceppaluni merged 12 commits into
hiero-ledger:mainfrom
Adityarya11:feat/getAccInfo-tck#2040
May 7, 2026
Merged

feat: implemented getAccountInfoQuery TCK endpoint#2081
aceppaluni merged 12 commits into
hiero-ledger:mainfrom
Adityarya11:feat/getAccInfo-tck#2040

Conversation

@Adityarya11

Copy link
Copy Markdown
Contributor

Description:
This PR implements the GetAccountInfo tck endpoint, to the sdk. The following code matches the tck test implementation, and the existing schema of the tck response, handler and params.


Note for Reviewers:
I have taken some implementation help from the JS sdk, but the complete implementation remains valid for the python sdk.


Related issue(s):

Fixes #2040


Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@Adityarya11 Adityarya11 changed the title Feat/get acc info tck#2040 feat: implemented getAccountInfoQuery TCK endpoint Apr 6, 2026
@codacy-production

codacy-production Bot commented Apr 6, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@codecov

codecov Bot commented Apr 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2081      +/-   ##
==========================================
- Coverage   93.75%   93.72%   -0.04%     
==========================================
  Files         145      145              
  Lines        9508     9507       -1     
==========================================
- Hits         8914     8910       -4     
- Misses        594      597       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

Hi, this is WorkflowBot.
Your pull request cannot be merged as it is not passing all our workflow checks.
Please click on each check to review the logs and resolve issues so all checks pass.
To help you:

@Adityarya11
Adityarya11 force-pushed the feat/getAccInfo-tck#2040 branch from 4b1f574 to 4f74d1c Compare April 6, 2026 19:36
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

Hello, this is the OfficeHourBot.

This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC).

This session provides an opportunity to ask questions regarding this Pull Request.

Details:

Disclaimer: This is an automated reminder. Please verify the schedule here for any changes.

From,
The Python SDK Team

@Adityarya11
Adityarya11 requested a review from manishdait April 13, 2026 05:00
@manishdait

Copy link
Copy Markdown
Contributor

@Adityarya11, is this ready fro review

@exploreriii

Copy link
Copy Markdown
Contributor

btw you can delete the cahngelog please

@Adityarya11
Adityarya11 force-pushed the feat/getAccInfo-tck#2040 branch from 4f74d1c to ca6e329 Compare April 13, 2026 12:13
@Adityarya11
Adityarya11 marked this pull request as ready for review April 13, 2026 12:13
@Adityarya11
Adityarya11 requested review from a team as code owners April 13, 2026 12:13
@github-actions github-actions Bot added skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples scope: tests involves unit, integration, fuzz or TCK tests labels Apr 13, 2026
@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Implements the TCK getAccountInfo JSON-RPC endpoint: adds request params and response models, a handler that executes AccountInfoQuery and maps SDK AccountInfo to TCK response format, relaxes AccountInfoQuery request validation to allow unset account IDs, and updates a unit test to match the new behavior.

Changes

TCK getAccountInfo feature

Layer / File(s) Summary
Data Shape
tck/response/account.py
Adds StakingInfoResponse, TokenRelationshipResponse, and GetAccountInfoResponse dataclasses; collection fields use field(default_factory=...).
Request Parsing
tck/param/account.py
Adds GetAccountInfoParams(BaseParams) with accountId and parse_json_params. Adjusts CreateAccountParams.parse_json_params return annotation.
Core Implementation
tck/handlers/account.py
Adds @rpc_method("getAccountInfo") handler and helper mappers: enum extraction, key serialization, staking info conversion, token relationships conversion, and response assembly. Adds module docstring and a docstring for create_account.
Integration / Execution
tck/handlers/account.py
Handler constructs AccountInfoQuery (uses sessionId, optional accountId), executes it, and returns GetAccountInfoResponse built from SDK AccountInfo.

Query behavior and tests

Layer / File(s) Summary
Behavior Change
src/hiero_sdk_python/query/account_info_query.py
Removes early ValueError for missing account_id in _make_request; always builds Query protobuf and sets accountID only when self.account_id is not None.
Tests
tests/unit/account_info_query_test.py
Replaces test expecting ValueError with a test that simulates a precheck INVALID_ACCOUNT_ID response and asserts PrecheckError is raised with status == ResponseCode.INVALID_ACCOUNT_ID.

Sequence Diagram

sequenceDiagram
    actor Client as JSON-RPC Client
    participant Handler as getAccountInfo Handler
    participant Params as GetAccountInfoParams
    participant Query as AccountInfoQuery
    participant SDK as Hiero SDK
    participant Mapper as Response Mapper

    Client->>Handler: JSON-RPC request (params)
    Handler->>Params: parse_json_params(params)
    Params-->>Handler: GetAccountInfoParams
    Handler->>Query: construct AccountInfoQuery(sessionId, optional accountId)
    Handler->>SDK: execute(query, client)
    SDK-->>Handler: AccountInfo
    Handler->>Mapper: build response from AccountInfo
    Mapper-->>Handler: GetAccountInfoResponse
    Handler-->>Client: JSON-RPC response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: implemented getAccountInfoQuery TCK endpoint' clearly summarizes the main change: implementing a new GetAccountInfo TCK endpoint with the getAccountInfoQuery functionality.
Description check ✅ Passed The description explains the PR implements the GetAccountInfo TCK endpoint, references the matching TCK test specification, mentions implementation help from the JS SDK, and lists completed checklist items (documentation and tests).
Linked Issues check ✅ Passed The PR addresses issue #2040 by adding GetAccountInfoParams dataclass, implementing the @rpc_method('getAccountInfo') handler, mapping SDK responses to TCK format, and updating AccountInfoQuery to handle missing account_id without raising ValueError.
Out of Scope Changes check ✅ Passed All changes are within scope: adding GetAccountInfoParams/response models, implementing the handler, updating AccountInfoQuery behavior, and adding unit tests—all aligned with the #2040 requirements for the getAccountInfo TCK endpoint.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2040

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 66ae908c-c9e2-4430-a432-5bd2536963f1

📥 Commits

Reviewing files that changed from the base of the PR and between c0d2625 and ca6e329.

📒 Files selected for processing (4)
  • tck/handlers/account.py
  • tck/param/account.py
  • tck/response/account.py
  • tests/tck/test_account_info.py

Comment thread tck/handlers/account.py Outdated
Comment thread tests/tck/test_account_info.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements the TCK JSON-RPC getAccountInfo endpoint in the tck/ server layer, including parameter parsing, SDK query execution, and response-shape mapping aligned to the TCK spec.

Changes:

  • Added getAccountInfo handler that runs AccountInfoQuery and maps AccountInfo → TCK response fields.
  • Introduced GetAccountInfoParams and new account-info response dataclasses (GetAccountInfoResponse, StakingInfoResponse, TokenRelationshipResponse).
  • Added unit tests validating params parsing, success mapping, and error mapping for missing/invalid accountId and SDK PrecheckError.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/tck/test_account_info.py Adds unit tests for getAccountInfo parsing, mapping, and error behavior.
tck/handlers/account.py Registers and implements getAccountInfo handler plus response-mapping helpers.
tck/param/account.py Adds GetAccountInfoParams parsing for accountId + sessionId.
tck/response/account.py Adds response dataclasses for account info, staking info, and token relationships.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tck/handlers/account.py
Comment thread tck/handlers/account.py
Comment thread tests/tck/test_account_info.py Outdated
Comment thread tck/handlers/account.py Outdated
Comment thread tck/handlers/account.py Outdated
Comment thread tck/handlers/account.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tck/handlers/account.py (1)

177-187: ⚠️ Potential issue | 🔴 Critical

Map getAccountInfo input/query failures to JSON-RPC errors instead of leaking exceptions.

Line 183-186 currently allows missing/invalid accountId and SDK query failures to escape uncaught. This breaks the required error contract for missing-id, invalid-id, and precheck/error mapping paths.

🐛 Proposed fix
 `@rpc_method`("getAccountInfo")
 def get_account_info(params: GetAccountInfoParams) -> GetAccountInfoResponse:
     """Query account info and map SDK fields to the TCK response contract."""
     client = get_client(params.sessionId)

+    if params.accountId is None or params.accountId == "":
+        raise JsonRpcError.invalid_params("accountId is required")
+
     query = AccountInfoQuery().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT)
-    if params.accountId is not None:
-        query.set_account_id(AccountId.from_string(params.accountId))
-
-    info = query.execute(client)
+    try:
+        query.set_account_id(AccountId.from_string(params.accountId))
+    except (TypeError, ValueError) as error:
+        raise JsonRpcError.hiero_error(
+            {"status": ResponseCode.INVALID_ACCOUNT_ID.name}
+        ) from error
+
+    try:
+        info = query.execute(client)
+    except PrecheckError as error:
+        raise JsonRpcError.hiero_error({"status": error.status.name}) from error
+
     return _build_account_info_response(info)
#!/bin/bash
# Verify expected error-contract coverage and current implementation behavior.
rg -n -C3 '\bdef get_account_info\b|AccountId\.from_string|query\.execute|JsonRpcError|PrecheckError|INVALID_ACCOUNT_ID|INVALID_PARAMS' tck/handlers/account.py
rg -n -C3 'getAccountInfo|missing id|invalid id|deleted account|precheck|HIERO_ERROR|INVALID_PARAMS|INVALID_ACCOUNT_ID' --iglob '*test*.py'

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c36a4c45-0bec-45d1-9fa0-ba022ef09208

📥 Commits

Reviewing files that changed from the base of the PR and between ca6e329 and a8f429d.

📒 Files selected for processing (3)
  • tck/handlers/account.py
  • tck/param/account.py
  • tck/response/account.py

Comment thread tck/handlers/account.py Outdated
@exploreriii exploreriii added step: 1st 1st stage of the review approval process status: ready for review and removed reviewer: committer labels Apr 14, 2026

@manishdait manishdait left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @Adityarya11, added some changes rest seems good to me.

Comment thread tck/handlers/account.py Outdated
Comment thread tests/unit/account_info_query_test.py
@exploreriii
exploreriii marked this pull request as ready for review May 5, 2026 11:41
@exploreriii exploreriii added step: 1st 1st stage of the review approval process reviewer: committer request review help from a committer labels May 5, 2026
Adityarya11 added 10 commits May 5, 2026 17:53
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Signed-off-by: Adityarya11 <arya050411@gmail.com>
@Adityarya11
Adityarya11 force-pushed the feat/getAccInfo-tck#2040 branch from c5d7f2d to 5d8f6d7 Compare May 5, 2026 13:04
@Adityarya11
Adityarya11 requested a review from manishdait May 5, 2026 13:04
@codacy-production

codacy-production Bot commented May 5, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@Adityarya11

Copy link
Copy Markdown
Contributor Author

@hiero-ledger/hiero-sdk-python-committers
@hiero-ledger/hiero-sdk-python-maintainers

review?!

@exploreriii

Copy link
Copy Markdown
Contributor

I can't review this right now, I don't have un-compromised hours of free time currently, i just have a few minutes/here/there

@Adityarya11

Copy link
Copy Markdown
Contributor Author

I can't review this right now, I don't have un-compromised hours of free time currently, i just have a few minutes/here/there

Yeah @exploreriii
Np

@exploreriii exploreriii added the reviewer: community pull requests looking for community reviews label May 7, 2026

@manishdait manishdait left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine to me

@manishdait manishdait added step: 2nd second stage of the review approval process and removed step: 1st 1st stage of the review approval process labels May 7, 2026

@aceppaluni aceppaluni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work

@aceppaluni
aceppaluni merged commit 8639a12 into hiero-ledger:main May 7, 2026
29 checks passed
NssGourav pushed a commit to NssGourav/hiero-sdk-python that referenced this pull request May 14, 2026
Signed-off-by: Adityarya11 <arya050411@gmail.com>
manishdait pushed a commit to manishdait/hiero-sdk-python that referenced this pull request May 18, 2026
Signed-off-by: Adityarya11 <arya050411@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewer: committer request review help from a committer reviewer: community pull requests looking for community reviews scope: tests involves unit, integration, fuzz or TCK tests skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples step: 2nd second stage of the review approval process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Advanced]: TCK test implement getAccountInfo

5 participants